# -*- encoding=utf8 -*-
"""
RedFlag-TC000006   多选素材
最大选择素材为8个场景
"""
__author__ = "ldm"

import sys
import os


# 获取当前脚本所在目录.py
current_dir = os.path.dirname(os.path.abspath(__file__))
# 获取上级目录.air
parent_dir = os.path.dirname(current_dir)
# 获取上级目录air
grandparent_dir = os.path.dirname(parent_dir)
# 获取和air目录平级的conf、testcase目录路径
conf_dir = os.path.join(grandparent_dir, 'conf')
testcase_dir = os.path.join(grandparent_dir, 'testcase')
# 将conf、testcase目录添加到sys.path
sys.path.append(conf_dir)
sys.path.append(testcase_dir)

from PageFunction import CameraVideoShooter
from elements import *
auto_setup(__file__)

shooter = CameraVideoShooter()
log("---------------------------------------------最大选择素材为8个场景---------------------------------------------------------")
# 进入相册
shooter.enter_album()
# 进行循环点击操作
shooter.click_child_nodes(album_select_button, 0, 2)

# 选择两个照片
shooter.click_element(album_photo_list)
shooter.click_child_nodes(poco("cn.migu.video.clip.walle:id/dokit_app_contentview_id").offspring("cn.migu.video.clip.walle:id/clip_rc_album_layout").offspring("cn.migu.video.clip.walle:id/clip_rc_sticky_content").offspring("cn.migu.video.clip.walle:id/clip_album_vpg").child("android.widget.RelativeLayout").offspring("cn.migu.video.clip.walle:id/clip_rc_album_rcv").child("cn.migu.video.clip.walle:id/clip_ed_item_rl"),0,4)
text = shooter.get_element_text(album_next_button)
# 断言
shooter.assert_texts_equal(text, "下一步(8)", "断言失败，预期文案与实际文案不符合")

# 最大选择8个提示
shooter.assert_toast_popup(album_select_button[8],r"tpl1749788471668.png", "断言失败，并未发现toast弹窗", record_pos=(-0.002, -0.008), resolution=(1224, 2700), threshold=0.5)
shooter.click_element(album_next_button)
shooter.wait_for_element_appearance(decoration_page_return_button, 5)
shooter.click_element(tip_to_crop_pop_up_window_correct)
shooter.assert_element_exists(decoration_page_release_video, "断言失败，未进入装饰页")
#关闭应用
stop_app(UGC_package_name)

